$OpenBSD: patch-cmake_modules_FindGLIB2_cmake,v 1.1 2017/01/31 09:58:35 sthen Exp $
Avoid messing up between paths found by pkg-config and CMake itself.
--- cmake/modules/FindGLIB2.cmake.orig	Sun Nov 15 18:07:26 2015
+++ cmake/modules/FindGLIB2.cmake	Sun Jan 29 10:12:03 2017
@@ -1,6 +1,6 @@
 IF (NOT MSVC)
     INCLUDE(FindPkgConfig)
-    PKG_SEARCH_MODULE( GLIB2 REQUIRED glib-2.0 )
+    PKG_SEARCH_MODULE(PC_GLIB2  REQUIRED glib-2.0 )
     IF(WIN32 AND NOT BUILD_STATIC)
         FIND_FILE(GLIB2_DLL 
                 NAMES glib-2.dll glib-2-vs9.dll libglib-2.0-0.dll
@@ -9,10 +9,10 @@ IF (NOT MSVC)
     ENDIF()
 ENDIF()
 
-IF (NOT GLIB2_FOUND OR NOT PKG_CONFIG_FOUND)
     FIND_PATH(GLIB2_GLIB2CONFIG_INCLUDE_PATH
         NAMES glibconfig.h
         PATHS
+          ${PC_GLIB2_LIBDIR}
           /usr/local/lib
           /usr/lib
           /usr/lib64
@@ -23,9 +23,10 @@ IF (NOT GLIB2_FOUND OR NOT PKG_CONFIG_FOUND)
     )
 
 
-    FIND_PATH(GLIB2_INCLUDE_DIRS
+    FIND_PATH(GLIB2_INCLUDE_DIR
         NAMES glib.h
         PATHS
+            ${PC_GLIB2_INCLUDEDIR}
             /usr/local/include
             /usr/include
             /opt/local/include
@@ -33,19 +34,19 @@ IF (NOT GLIB2_FOUND OR NOT PKG_CONFIG_FOUND)
         PATH_SUFFIXES gtk-2.0 glib-2.0 glib20 
     )
 
-    FIND_LIBRARY(GLIB2_LIBRARIES
+     FIND_LIBRARY(GLIB2_LIBRARY
         NAMES  glib-2.0 glib20 glib
         PATHS  
+            ${PC_GLIB2_LIBDIR}
             /usr/local/lib
             /usr/lib
             /usr/lib64
             /opt/local/lib
             ${GLIB2_BASE_DIR}/lib
     )
-    
-    IF(GLIB2_GLIB2CONFIG_INCLUDE_PATH AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES)
-        SET( GLIB2_INCLUDE_DIRS  ${GLIB2_GLIB2CONFIG_INCLUDE_PATH} ${GLIB2_INCLUDE_DIRS} )
-        SET( GLIB2_LIBRARIES ${GLIB2_LIBRARIES} )
+    IF(GLIB2_GLIB2CONFIG_INCLUDE_PATH AND GLIB2_INCLUDE_DIR AND GLIB2_LIBRARY)
+        SET( GLIB2_INCLUDE_DIRS  ${GLIB2_GLIB2CONFIG_INCLUDE_PATH} ${GLIB2_INCLUDE_DIR} )
+        SET( GLIB2_LIBRARIES ${GLIB2_LIBRARY} )
         SET( GLIB2_FOUND 1 )
     ELSE()
         SET( GLIB2_INCLUDE_DIRS )
@@ -59,7 +60,6 @@ IF (NOT GLIB2_FOUND OR NOT PKG_CONFIG_FOUND)
                 PATHS "${GLIB2_BASE_DIR}/bin"
                 NO_SYSTEM_ENVIRONMENT_PATH)
     ENDIF()    
-ENDIF ()
 
 #INCLUDE( FindPackageHandleStandardArgs )
 #FIND_PACKAGE_HANDLE_STANDARD_ARGS( GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_GLIB2CONFIG_INCLUDE_PATH GLIB2_GLIB2_INCLUDE_PATH )
